QuickTime 3 Reference

Previous | Chapter Top | Contents

Using the Standard Sound Component

In order to work with the Standard Sound Component, it is necessary to open a connection to the component using the Component Manager. An example of how to do this is shown in Listing 23-1 .

Listing 1 Opening a connection to the Standard Sound Component

ComponentInstance ci;
ci = OpenDefaultComponent(StandardCompressionType,
        StandardCompressionSubTypeSound);

After obtaining a connection to the Standard Sound Component, it may be appropriate to configure the dialog to present a reasonable set of values. This is done with SCSetInfo as shown in Listing 23-2 . This example sets the sample rate to 32000 Hz, the sample size to 8 bits, the channel count to 1, and the compression format to MACE 6:1. If SCSetInfo is not called for a given parameter, that parameter will default to an appropriate value.

Listing 2 Setting initial values for the dialog

UnsignedFixed rate;
short sSize, cCount;
OSType compType;
rate = FixRatio(32000, 1);
SCSetInfo(ci, scSoundSampleRateType, &rate);
sSize = 8;
SCSetInfo(ci, scSoundSampleSizeType, &sSize);
cCount = 1;
SCSetInfo(ci, scSoundChannelCountType, &cCount);
compType = kMACE6Compression;
SCSetInfo(ci, scSoundCompressionType, &compType);

It is sometimes necessary to restrict the list of compression types appearing in the compression menu. For example, some clients may not support generation of compressed data. The Standard Sound Component allows the client to provide a list of compression types that should be displayed. In the following example in Listing 23-3 , all compression types except for uncompressed are eliminated from the list.

Listing 3 Restricting the list of compression types

Handle compressionTypeList;
compressionTypeList = NewHandle(sizeof(OSType));
**(OSType **)compressionTypeList = kRawCodecType;
SCSetInfo(ci, scCompressionListType, &compressionTypeList);

To display the dialog, use SCRequestImageSettings as shown in Listing 23-4 . If the user cancels the dialog, userCanceledErr is returned.

Listing 4 Displaying the dialog

OSErr err;
err = SCRequestImageSettings(ci);

After the dialog has been displayed, the settings can be retrieved using the SCGetInfo call with the appropriate selectors. The example in Listing 23-5 shows how to retrieve the selected sample rate, sample size, compression format, and number of channels.

Listing 5 Retrieving settings from the dialog

UnsignedFixed rate;
short sSize, cCount;
OSType compType;
SCGetInfo(ci, scSoundSampleRateType, &rate);
SCGetInfo(ci, scSoundSampleSizeType, &sSize);
SCGetInfo(ci, scSoundChannelCountType, &cCount);
SCGetInfo(ci, scSoundCompressionType, &compType);

It is also possible to retrieve all of the current settings in a single Handle, as shown in the next example. This can be convenient when saving user settings.

Handle h;
SCGetInfo(ci, scSettingsStateType, &h);

Once the settings have been retrieved in the handle, they can be restored using SCSetInfo as show as follows.

SCSetInfo(ci, scSettingsStateType, &h);

When you are finished with the Standard Sound Component, close the connection to the component as shown as follows.

CloseComponent(ci);

Constants

The following constants have been added to the list of selectors that can be passed to SCGetInfo and SCSetInfo . These selectors are only supported by the Standard Sound Dialog, not the Standard Compression Dialog.

scSoundSampleRateType
A pointer to an UnsignedFixed value that represents the current sample rate.
scSoundSampleSizeType
A pointer to a short integer that represents the current sample size. This value will be either 8 or 16.
scSoundChannelCountType
A pointer to a short integer that represents the current number of channels. This value will be either 1 or 2.
scSoundCompressionType
A pointer to an OSType that represents the current compression type. This value will either be kRawCodecType or one of the available sound compression formats.
scCompressionListType
A pointer to a Handle containing an array of OSTypes that indicate the sound compression formats that may be presented to the user. Pass NIL to SCSetInfo to reset the list to all available sound compression formats.

The Standard Sound Component also supports the following selectors.

scPreferenceFlagsType
The only flag that is supported in the preferences is scUseMovableModal . All other flags should be set to zero. The preference flags are initialized to scUseMovableModal when the Standard Sound Dialog is instantiated.
scExtendedProcsType
The only fields supported are filterProc and refcon . All other fields should be initialized to zero. The filter procedure should only be used to update background windows. It should not be used to intercept user interactions in the dialog window itself.
scSettingsStateType
This selector is supported in the same way as in the Standard Compression Component.

Functions

The Standard Sound Component implements the following functions from the Standard Compression Component interface. For more details, see the Standard Compression Component chapter of Inside Macintosh: QuickTime Components .

SCGetInfo
This function supports all of the selectors documented in the Constants section. If an unsupported selector is used, it returns scTypeNotFoundErr .
SCSetInfo
This function supports all of the selectors documented in the Constants section. If an unsupported selector is used, it returns scTypeNotFoundErr .
SCRequestImageSettings
This function displays the sound settings dialog. If the user cancels the dialog, the userCanceledErr is returned. To provide a filter procedure to process events while the dialog is displayed, use SCSetInfo with the scExtendedProcsType selector.

 


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Contents